package com.servlet;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.omg.CORBA.portable.OutputStream;

import com.easywan.utils.Config;

public class VideoGetServlet extends HttpServlet{
	private static final long serialVersionUID = 1L;
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String fileName = req.getParameter("fileName");
		String des = req.getParameter("des");
		File file = null;
		if("des".equals(des)){
			file = new File(Config.get("videoDesPath")+"/"+fileName);
		}
		FileInputStream in = new FileInputStream(file);
		ServletOutputStream out = resp.getOutputStream();
		byte[] buffer = new byte[1024];
		while(in.read(buffer) != -1)
			out.write(buffer);
		in.close();
		//req.getRequestDispatcher("/video.jsp").forward(req, resp);
	}
}
